package com.cloud.drore.eboss.supplier.controller;

import com.cloud.drore.eboos.common.base.ResultMessage;
import com.cloud.drore.eboos.exception.BusinessException;
import com.cloud.drore.eboss.login.user.Anon;
import com.cloud.drore.eboss.supplier.entity.po.GetProductByOTAResponsePo;
import com.cloud.drore.eboss.supplier.entity.po.ProductForFeeAndRefundFeePo;
import com.cloud.drore.eboss.supplier.entity.vo.ProductForFeeAndRefundFeeVo;
import com.cloud.drore.eboss.supplier.service.impl.ProductSynchronizationImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: 同步畅游通产品信息<br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/3/14 0014 下午 3:00 <br>
 * @Author: <a href="410508961@qq.com">夏凯</a>
 */
@RestController
@RequestMapping("/productSynchronization")
@Api(value = "/畅游通产品信息同步接口", description = "畅游通产品信息同步接口-夏凯")
public class ProductSynchronizationController {
    @Autowired
    ProductSynchronizationImpl productSynchronizationImpl;

    @Anon
    @ApiOperation(value = "畅游通产品插入门票和公共数据")
    @PostMapping(value = "/ticketSynchronize")
    public ResultMessage ticketSynchronize(@RequestBody GetProductByOTAResponsePo getProductByOTAResponsePo) {
        ResultMessage resultMessage = productSynchronizationImpl.insertIntoProductInfoList(getProductByOTAResponsePo);
        return resultMessage;
    }

    @Anon
    @ApiOperation(value = "通过游玩时间，总金额，公共产品id，产品类型 获得费率和退款手续费")
    @PostMapping(value = "/selectFeeAndRefundFee")
    public ResultMessage<ProductForFeeAndRefundFeeVo> selectFeeAndRefundFee(@RequestBody @Valid ProductForFeeAndRefundFeePo p) throws BusinessException {
        ResultMessage resultMessage = productSynchronizationImpl.getFeeAndRefundFee(p.getProductId(), p.getProductTotalPrice(), p.getPlayDate(), p.getProductType());
        return resultMessage;
    }
}
